package com.jmp.security.grant.wx;

import com.jmp.security.base.RequestDetail;
import com.jmp.base.dto.ClientEnum;
import lombok.Builder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import one.stand.advice.ResultEnum;
import one.stand.enums.LoginEnum;
import one.stand.util.AssertUtil;

@Data
@Builder
@Slf4j
public class WxAppRquestDetail implements RequestDetail {
    /**
     * 登陆程序名
     */
    private LoginEnum loginEnum;
    /**
     * 登陆client key
     */
    private String companyKey;

    /**
     * 微信第三方授权登录
     */
    private AppOauth appOauth;

    /**
     * push
     */
    private String pushCid;
    private ClientEnum clientEnum;

    @Override
    public String getEquCode() {
        return null;
    }

    @Override
    public Integer getEquCodeType() {
        return null;
    }

    @Override
    public void initAfter() {
        AssertUtil.nonNull(loginEnum, ResultEnum.PARAM_CHECK);
        AssertUtil.nonNull(companyKey, ResultEnum.PARAM_CHECK);
        AssertUtil.nonNull(appOauth, ResultEnum.PARAM_CHECK);
        AssertUtil.nonNull(appOauth.getOpenId(), ResultEnum.PARAM_CHECK);
//        AssertUtil.nonNull(appOauth.getUnionid(), ResultEnum.PARAM_CHECK);
    }

    @Data
    @Builder
    public static class AppOauth {
        private String openId;
        private String unionid;
        private String sessionKey;
        private String userInfo;
    }
}